package com.cleaningcloud.cld.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldAssetsDetails;
import com.cleaningcloud.cld.service.ICldAssetsDetailsService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 资产明细Controller
 * 
 * @author cleaningcloud
 * @date 2024-10-06
 */
@RestController
@RequestMapping("/details")
public class CldAssetsDetailsController extends BaseController
{
    @Autowired
    private ICldAssetsDetailsService cldAssetsDetailsService;

    /**
     * 查询资产明细列表
     */
//    @RequiresPermissions("erp:details:list")
    @GetMapping("/list")
    public TableDataInfo list(CldAssetsDetails cldAssetsDetails)
    {
        startPage();
        List<CldAssetsDetails> list = cldAssetsDetailsService.selectCldAssetsDetailsList(cldAssetsDetails);
        return getDataTable(list);
    }

    /**
     * 导出资产明细列表
     */
//    @RequiresPermissions("erp:details:export")
    @Log(title = "资产明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CldAssetsDetails cldAssetsDetails)
    {
        List<CldAssetsDetails> list = cldAssetsDetailsService.selectCldAssetsDetailsList(cldAssetsDetails);
        ExcelUtil<CldAssetsDetails> util = new ExcelUtil<CldAssetsDetails>(CldAssetsDetails.class);
        util.exportExcel(response, list, "资产明细数据");
    }

    /**
     * 获取资产明细详细信息
     */
//    @RequiresPermissions("erp:details:query")
    @GetMapping(value = "/{assetsDetailsId}")
    public AjaxResult getInfo(@PathVariable("assetsDetailsId") Long assetsDetailsId)
    {
        return success(cldAssetsDetailsService.selectCldAssetsDetailsByAssetsDetailsId(assetsDetailsId));
    }

    /**
     * 新增资产明细
     */
//    @RequiresPermissions("erp:details:add")
    @Log(title = "资产明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldAssetsDetails cldAssetsDetails)
    {
        return toAjax(cldAssetsDetailsService.insertCldAssetsDetails(cldAssetsDetails));
    }

    /**
     * 修改资产明细
     */
//    @RequiresPermissions("erp:details:edit")
    @Log(title = "资产明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldAssetsDetails cldAssetsDetails)
    {
        return toAjax(cldAssetsDetailsService.updateCldAssetsDetails(cldAssetsDetails));
    }

    /**
     * 删除资产明细
     */
//    @RequiresPermissions("erp:details:remove")
    @Log(title = "资产明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{assetsDetailsIds}")
    public AjaxResult remove(@PathVariable Long[] assetsDetailsIds)
    {
        return toAjax(cldAssetsDetailsService.deleteCldAssetsDetailsByAssetsDetailsIds(assetsDetailsIds));
    }
}
